<template>
<span class="op_dir_Mbind-wrapper">
  <button v-if="btns.tocopy" title="复制到其它模型"
          class="ui circular icon primary button tiny"
          @click.stop.prevent="tocopy()">
          <i class="icon copy"></i>
        </button>
  <btn_group v-if="btns.showType_btns&&showType_btns" @btnClick="btnClick" :btns="showType_btns" field="showType" title="展示类型" :confirm="true"></btn_group>
</span>
</template>
<script type="text/ecmascript-6">
    import tool from 'src/util/tool';
    import util from '_util/index';
    import logic from '_logic';
    import in_array from 'in_array';

    import btn_group from 'components/common/btn_group';


    export default {
        data() {
            return {
                detail_info: null,
                showType_btns: null
            }
        },
        components: {
            btn_group
        },
        methods: {
            tocopy(){

                logic.list.checkIds(this, (selected_ids) => {

                    util.showMybind(this, {
                        bindModel: 4,
                        title: '请选择要复制到的模型',
                        name: 'mid',
                        _id: 'op/Mbind'
                    }, (fname, val, title) => {
                        let mid = val;
                        if (mid) {
                            let url = tool.getApi(this, 'Post', 'copyMbind');
                            util.http.SR(this, url, {mid, selected_ids}, '复制成功');
                        }
                    });
                },'请选择要复制的数据');
            },
            btnClick(flag, field){
                logic.list.checkIds(this, (selected_ids) => {
                    let url = tool.getApi(this, this.ctl, 'set');
                    let param = {
                        type: 'onOff',
                        field,
                        flag,
                        ids: selected_ids
                    };
                    util.http.SR(this, url, param, '操作成功', (rs) => {
                        logic.list.refreshListData(this);
                    });
                });
            },
            getBtns(){
                let obj =
                    {
                        'show_type': 'showType_btns'
                    }

                logic.list.getListOpBtns(this, obj)
            }
        },
        computed: {
            ctl(){
                return this.$route.query.ctl;
            },
            is_admin(){
                return util.is_admin(this);
            },
        },
        props: ['btns'],
        created() {
            this.getBtns()
        },
    };
</script>
<style rel="stylesheet/less" lang="less">@dir: "header/";</style>
